package com.cashmate.struts;

import com.cashmate.hibernate.dao.CreditinvestigationDAO;
import com.cashmate.hibernate.pojo.Creditinvestigations;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Result;


import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;

public class EditCreditinv extends ActionSupport {
 
    //private LoanapplicationDAO loanappDAO = (LoanapplicationDAO) ServletActionContext.getServletContext().getAttribute("loanapplicationDAO");
    private CreditinvestigationDAO creditDAO = (CreditinvestigationDAO) ServletActionContext.getServletContext().getAttribute("creditinvestigationDAO");
//  private String releasedate;
//  private int suggestedamount;
//  private String firstlast;
//  private String secondlast;
    private String nickname;//
    private String addressfloorarea;//
    private String addresslotarea;//
    private String addressstability;//
    private String addressmodel;//
    private String addressmake;//
    private String addressland;//
    private String addressmonthlyrental;//
    private String addresslandlordname;//
    private String addresslandlordaddress;//
    private String addresslandlordphoneno;//
    private String spousedegree;//
    private String spouseschool;//
    private String spouseyeargraduated;//
    private String previousstreetaddress;//
    private String previousbarangay;//
    private String previouscityormunicipality;//
    private String previousprovince;//
    private String previouspostalcode;//
    private String previouslengthofstayinyears;//
    private String previouslengthofstayinmonths;//
    private String parentsstreetaddress;//
    private String parentsbarangay;//
    private String parentscityormunicipality;//
    private String parentsprovince;//
    private String parentspostalcode;//
    private String parentslengthofstayinyear;//
    private String parentslengthofstayinmonths;//
    private String fatherinlawfirstname;//
    private String fatherinlawmiddlename;//
    private String fatherinlawlastname;//
    private String motherinlawfirstname;//
    private String motherinlawmiddlename;//
    private String motherinlawlastname;//
    private String fatherinlawemployer;//
    private String motherinlawemployer;//
    private String fatherinlawposition;//
    private String motherinlawposition;//
    private String fatherinlawage;//
    private String motherinlawage;//
    private String parentsinlawstreetaddress;//
    private String parentsinlawbarangay;//
    private String parentsinlawcityormunicipality;//
    private String parentsinlawprovince;//
    private String parentsinlawpostalcode;//
    private String parentsinlawlengthofstayinyears;//
    private String parentsinlawlengthofstayinmonths;//
    private String presentaddresslengthofstayinyears;//
    private String presentaddresslengthofstayinmonths;//
    private String presentaddressstatus;
    private int id;
    private String loc;

    @Actions({
        @Action(value = "/edit-creditinvestigation", results = {
            @Result(location = "${loc}", name = "success"),
            @Result(location = "${loc}", name = "input")
        })
    })
    @Override
    public String execute() throws Exception {
        loc = "../../loanapplication.jsp?cat=gridappl";
//        if (releasedate != null) {
//            Loanapplications la = loanappDAO.getById(id);
//            la.setReleasedate(releasedate);
//            loanappDAO.update(la);
//        }
//
//        if (firstlast != null) {
//            Loanapplications la = loanappDAO.getById(id);
//            if (la.getFirstlastpn() > 0) {
//                Loans loan = la.getBorrowers().getFirstlast();
//                loan.setModeofpayment(firstlast);
//                loanDAO.update(loan);
//            }
//
//        }
//
//        if (secondlast != null) {
//            Loanapplications la = loanappDAO.getById(id);
//            if (la.getSecondlastpn() > 0) {
//                Loans loan = la.getBorrowers().getSecondlast();
//                loan.setModeofpayment(secondlast);
//                loanDAO.update(loan);
//            }
//        }
//
//        if (suggestedamount > 0) {
//            Loanapplications la = loanappDAO.getById(id);
//            la.setSuggestedamount(suggestedamount);
//            loanappDAO.update(la);
//        }

        if (nickname != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setStat("pending");
            c.setNickname(nickname);
            creditDAO.update(c);
        }
        if (addressfloorarea != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddressfloorarea(addressfloorarea);
            creditDAO.update(c);
        }
        if (addresslotarea != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddresslotarea(addresslotarea);
            creditDAO.update(c);
        }
        if (addressstability != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddressstability(addressstability);
            creditDAO.update(c);
        }
        if (addressmodel != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddressmodel(addressmodel);
            creditDAO.update(c);
        }
        if (addressmake != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddressmake(addressmake);
            creditDAO.update(c);
        }
        if (addressland != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddressland(addressland);
            creditDAO.update(c);
        }
        if (addressmonthlyrental != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddressmonthlyrental(addressmonthlyrental);
            creditDAO.update(c);
        }
        if (addresslandlordname != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddresslandlordname(addresslandlordname);
            creditDAO.update(c);
        }
        if (addresslandlordaddress != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddresslandlordaddress(addresslandlordaddress);
            creditDAO.update(c);
        }
        if (addresslandlordphoneno != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setAddresslandlordphoneno(addresslandlordphoneno);
            creditDAO.update(c);
        }
        if (spousedegree != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setSpousedegree(spousedegree);
            creditDAO.update(c);
        }
        if (spouseschool != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setSpouseschool(spouseschool);
            creditDAO.update(c);
        }
        if (spouseyeargraduated != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setSpouseyeargraduated(Integer.parseInt(spouseyeargraduated));
            creditDAO.update(c);
        }
        if (previousstreetaddress != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPreviousstreetaddress(previousstreetaddress);
            creditDAO.update(c);
        }
        if (previousbarangay != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPreviousbarangay(previousbarangay);
            creditDAO.update(c);
        }
        if (previouscityormunicipality != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPreviouscityormunicipality(previouscityormunicipality);
            creditDAO.update(c);
        }
        if (previousprovince != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPreviousprovince(previousprovince);
            creditDAO.update(c);
        }
        if (previouspostalcode != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPreviouspostalcode(previouspostalcode);
            creditDAO.update(c);
        }
        if (previouslengthofstayinyears != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPreviouslengthofstayinyears(Integer.parseInt(previouslengthofstayinyears));
            creditDAO.update(c);
        }
        if (previouslengthofstayinmonths != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPresentaddresslengthofstayinmonths(Integer.parseInt(previouslengthofstayinmonths));
            creditDAO.update(c);
        }
        if (parentsstreetaddress != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsstreetaddress(parentsstreetaddress);
            creditDAO.update(c);
        }
        if (parentsbarangay != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsbarangay(parentsbarangay);
            creditDAO.update(c);
        }
        if (parentscityormunicipality != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentscityormunicipality(parentscityormunicipality);
            creditDAO.update(c);
        }
        if (parentsprovince != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsprovince(parentsprovince);
            creditDAO.update(c);
        }
        if (parentspostalcode != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentspostalcode(parentspostalcode);
            creditDAO.update(c);
        }
        if (parentslengthofstayinyear != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawlengthofstayinyears(Integer.parseInt(parentslengthofstayinyear));
            creditDAO.update(c);
        }
        if (parentslengthofstayinmonths != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawlengthofstayinmonths(Integer.parseInt(parentslengthofstayinmonths));
            creditDAO.update(c);
        }
        if (fatherinlawfirstname != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setFatherinlawfirstname(fatherinlawfirstname);
            creditDAO.update(c);
        }
        if (fatherinlawmiddlename != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setFatherinlawmiddlename(fatherinlawmiddlename);
            creditDAO.update(c);
        }
        if (fatherinlawlastname != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setFatherinlawlastname(fatherinlawlastname);
            creditDAO.update(c);
        }
        if (motherinlawfirstname != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setMotherinlawfirstname(motherinlawfirstname);
            creditDAO.update(c);
        }
        if (motherinlawmiddlename != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setMotherinlawmiddlename(motherinlawmiddlename);
            creditDAO.update(c);
        }
        if (motherinlawlastname != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setMotherinlawlastname(motherinlawlastname);
            creditDAO.update(c);
        }
        if (fatherinlawemployer != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setFatherinlawemployer(fatherinlawemployer);
            creditDAO.update(c);
        }
        if (motherinlawemployer != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setMotherinlawemployer(motherinlawemployer);
            creditDAO.update(c);
        }
        if (fatherinlawposition != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setFatherinlawposition(fatherinlawposition);
            creditDAO.update(c);
        }
        if (motherinlawposition != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setMotherinlawposition(motherinlawposition);
            creditDAO.update(c);
        }
        if (fatherinlawage != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setFatherinlawage(Integer.parseInt(fatherinlawage));
            creditDAO.update(c);
        }
        if (motherinlawage != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setMotherinlawage(Integer.parseInt(motherinlawage));
            creditDAO.update(c);
        }
        if (parentsinlawstreetaddress != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawstreetaddress(parentsinlawstreetaddress);
            creditDAO.update(c);
        }
        if (parentsinlawbarangay != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawbarangay(parentsinlawbarangay);
            creditDAO.update(c);
        }
        if (parentsinlawcityormunicipality != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawcityormunicipality(parentsinlawcityormunicipality);
            creditDAO.update(c);
        }
        if (parentsinlawprovince != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawprovince(parentsinlawprovince);
            creditDAO.update(c);
        }
        if (parentsinlawpostalcode != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawpostalcode(parentsinlawpostalcode);
            creditDAO.update(c);
        }
        if (parentsinlawlengthofstayinyears != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawlengthofstayinyears(Integer.parseInt(parentsinlawlengthofstayinyears));
            creditDAO.update(c);
        }
        if (parentsinlawlengthofstayinmonths != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setParentsinlawlengthofstayinmonths(Integer.parseInt(parentsinlawlengthofstayinmonths));
            creditDAO.update(c);
        }
        if (presentaddresslengthofstayinyears != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPresentaddresslengthofstayinyears(Integer.parseInt(presentaddresslengthofstayinyears));
            creditDAO.update(c);
        }
        if (presentaddresslengthofstayinmonths != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPresentaddresslengthofstayinyears(Integer.parseInt(presentaddresslengthofstayinmonths));
            creditDAO.update(c);
        }
        if (presentaddressstatus != null) {
            Creditinvestigations c = creditDAO.get(id);
            c.setPresentaddressstatus(presentaddressstatus);
            creditDAO.update(c);
        }

        return NONE;
    }

    public void setAddressfloorarea(String addressfloorarea) {
        this.addressfloorarea = addressfloorarea;
    }

    public void setAddressland(String addressland) {
        this.addressland = addressland;
    }

    public void setAddresslandlordaddress(String addresslandlordaddress) {
        this.addresslandlordaddress = addresslandlordaddress;
    }

    public void setAddresslandlordname(String addresslandlordname) {
        this.addresslandlordname = addresslandlordname;
    }

    public void setAddresslandlordphoneno(String addresslandlordphoneno) {
        this.addresslandlordphoneno = addresslandlordphoneno;
    }

    public void setAddresslotarea(String addresslotarea) {
        this.addresslotarea = addresslotarea;
    }

    public void setAddressmake(String addressmake) {
        this.addressmake = addressmake;
    }

    public void setAddressmodel(String addressmodel) {
        this.addressmodel = addressmodel;
    }

    public void setAddressmonthlyrental(String addressmonthlyrental) {
        this.addressmonthlyrental = addressmonthlyrental;
    }

    public void setAddressstability(String addressstability) {
        this.addressstability = addressstability;
    }

    public void setFatherinlawage(String fatherinlawage) {
        this.fatherinlawage = fatherinlawage;
    }

    public void setFatherinlawemployer(String fatherinlawemployer) {
        this.fatherinlawemployer = fatherinlawemployer;
    }

    public void setFatherinlawfirstname(String fatherinlawfirstname) {
        this.fatherinlawfirstname = fatherinlawfirstname;
    }

    public void setFatherinlawlastname(String fatherinlawlastname) {
        this.fatherinlawlastname = fatherinlawlastname;
    }

    public void setFatherinlawmiddlename(String fatherinlawmiddlename) {
        this.fatherinlawmiddlename = fatherinlawmiddlename;
    }

    public void setFatherinlawposition(String fatherinlawposition) {
        this.fatherinlawposition = fatherinlawposition;
    }

    public void setMotherinlawage(String motherinlawage) {
        this.motherinlawage = motherinlawage;
    }

    public void setMotherinlawemployer(String motherinlawemployer) {
        this.motherinlawemployer = motherinlawemployer;
    }

    public void setMotherinlawfirstname(String motherinlawfirstname) {
        this.motherinlawfirstname = motherinlawfirstname;
    }

    public void setMotherinlawlastname(String motherinlawlastname) {
        this.motherinlawlastname = motherinlawlastname;
    }

    public void setMotherinlawmiddlename(String motherinlawmiddlename) {
        this.motherinlawmiddlename = motherinlawmiddlename;
    }

    public void setMotherinlawposition(String motherinlawposition) {
        this.motherinlawposition = motherinlawposition;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public void setParentsbarangay(String parentsbarangay) {
        this.parentsbarangay = parentsbarangay;
    }

    public void setParentscityormunicipality(String parentscityormunicipality) {
        this.parentscityormunicipality = parentscityormunicipality;
    }

    public void setParentsinlawbarangay(String parentsinlawbarangay) {
        this.parentsinlawbarangay = parentsinlawbarangay;
    }

    public void setParentsinlawcityormunicipality(String parentsinlawcityormunicipality) {
        this.parentsinlawcityormunicipality = parentsinlawcityormunicipality;
    }

    public void setParentsinlawlengthofstayinmonths(String parentsinlawlengthofstayinmonths) {
        this.parentsinlawlengthofstayinmonths = parentsinlawlengthofstayinmonths;
    }

    public void setParentsinlawlengthofstayinyears(String parentsinlawlengthofstayinyears) {
        this.parentsinlawlengthofstayinyears = parentsinlawlengthofstayinyears;
    }

    public void setParentsinlawpostalcode(String parentsinlawpostalcode) {
        this.parentsinlawpostalcode = parentsinlawpostalcode;
    }

    public void setParentsinlawprovince(String parentsinlawprovince) {
        this.parentsinlawprovince = parentsinlawprovince;
    }

    public void setParentsinlawstreetaddress(String parentsinlawstreetaddress) {
        this.parentsinlawstreetaddress = parentsinlawstreetaddress;
    }

    public void setParentslengthofstayinmonths(String parentslengthofstayinmonths) {
        this.parentslengthofstayinmonths = parentslengthofstayinmonths;
    }

    public void setParentslengthofstayinyear(String parentslengthofstayinyear) {
        this.parentslengthofstayinyear = parentslengthofstayinyear;
    }

    public void setParentspostalcode(String parentspostalcode) {
        this.parentspostalcode = parentspostalcode;
    }

    public void setParentsprovince(String parentsprovince) {
        this.parentsprovince = parentsprovince;
    }

    public void setParentsstreetaddress(String parentsstreetaddress) {
        this.parentsstreetaddress = parentsstreetaddress;
    }

    public void setPreviousbarangay(String previousbarangay) {
        this.previousbarangay = previousbarangay;
    }

    public void setPreviouscityormunicipality(String previouscityormunicipality) {
        this.previouscityormunicipality = previouscityormunicipality;
    }

    public void setPreviouslengthofstayinmonths(String previouslengthofstayinmonths) {
        this.previouslengthofstayinmonths = previouslengthofstayinmonths;
    }

    public void setPreviouslengthofstayinyears(String previouslengthofstayinyears) {
        this.previouslengthofstayinyears = previouslengthofstayinyears;
    }

    public void setPreviouspostalcode(String previouspostalcode) {
        this.previouspostalcode = previouspostalcode;
    }

    public void setPreviousprovince(String previousprovince) {
        this.previousprovince = previousprovince;
    }

    public void setPreviousstreetaddress(String previousstreetaddress) {
        this.previousstreetaddress = previousstreetaddress;
    }

    public void setSpousedegree(String spousedegree) {
        this.spousedegree = spousedegree;
    }

    public void setSpouseschool(String spouseschool) {
        this.spouseschool = spouseschool;
    }

    public void setSpouseyeargraduated(String spouseyeargraduated) {
        this.spouseyeargraduated = spouseyeargraduated;
    }

    public void setPresentaddresslengthofstayinmonths(String presentaddresslengthofstayinmonths) {
        this.presentaddresslengthofstayinmonths = presentaddresslengthofstayinmonths;
    }

    public void setPresentaddresslengthofstayinyears(String presentaddresslengthofstayinyears) {
        this.presentaddresslengthofstayinyears = presentaddresslengthofstayinyears;
    }

    public void setPresentaddressstatus(String presentaddressstatus) {
        this.presentaddressstatus = presentaddressstatus;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getLoc() {
        return loc;
    }
}
